<template>
  <view class="container">
    <view class="card">
        <view>头像</view>
        <view class="avatar">
          <image :src="userInfo.avatar?userInfo.avatar:'../../static/images/noavatar.png'" mode="scaleToFill" />
        </view>
    </view>
    <van-cell-group >
      <van-cell title="姓名" :value="userInfo.name" /> 
      <van-cell title="性别" :value="userInfo.gender" is-link /> 
      <van-cell title="岗位" :value="userInfo.positionName" /> 
      <van-cell title="手机号" :value="userInfo.phone" /> 
      <van-cell title="所在检察院" :value="userInfo.yardName" /> 
      <van-cell title="所在部门" :value="userInfo.orgName" /> 
    </van-cell-group>
    <view class="btn">
	<van-button type='primary'  class="w-full" >确定</van-button>
	<view style="margin-top:50rpx">
			<van-button type="default"  class="w-full" @click="quit">退出登录</van-button> 
	</view>
	</view>
    
    <view style="height: 100rpx;"></view>
  </view>
  
</template>
<script setup> 
  import {menuTreeSelectorApi,getLoginUserApi} from '@/api'
  import { onLoad,onShow } from '@dcloudio/uni-app';
  const userInfo=ref({}) 
 onShow(async()=>{
  const res = await getLoginUserApi();
  userInfo.value =res.data 
 })
 const routeTo=(url)=>{
   uni.navigateTo({
    url:url
   })
 }
 const quit = () => {
 	uni.showModal({
 		title: "提示",
 		content: "确定退出吗？",
 		success: function (res) {
 			if (res.confirm) {
 				cache.clear();
 				uni.reLaunch({
 					url: "/pages/login/index",
 				});
 			} else if (res.cancel) {
 			}
 		},
 	});
 };
</script>
<style lang="scss" scoped>
.card{
  background: #fff;
  padding: 30rpx 24rpx;
  font-size: 28rpx;
  align-items: center;
  justify-content: space-between;
  display: flex;
  .avatar{
    width: 100rpx;
    height: 100rpx;
    display: block;
    image{
      width: 100rpx;
      height: 100rpx;
      display: block;
      border-radius: 50%;
    }
  }
}
.btn{
  width: 93%; 
  margin: 100rpx auto;
}
</style>
